﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Xin478.CSWork.Client
{
    public partial class LeftMenuCtrl :UserControl
    {
        public event TreeNodeMouseClickEventHandler NodeMouseClick;

        public LeftMenuCtrl()
        {
            InitializeComponent();
            myTreeView1.NodeMouseClick+=new TreeNodeMouseClickEventHandler(myTreeView1_NodeMouseClick);
            myTreeView1.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(myTreeView1_NodeMouseDoubleClick);
            myTreeView1.NodeMouseHover += new TreeNodeMouseHoverEventHandler(myTreeView1_NodeMouseHover);
        }

        void myTreeView1_NodeMouseHover(object sender, TreeNodeMouseHoverEventArgs e)
        {
            MyMenuNode myMenuNode = e.Node as MyMenuNode;
            if (myMenuNode != null) myMenuNode.Hover();
        }

        void myTreeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            MyMenuNode myMenuNode = e.Node as MyMenuNode;
            if (myMenuNode != null) myMenuNode.DoubleClick();
        }

        void myTreeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            MyMenuNode myMenuNode=e.Node as MyMenuNode;
            if (myMenuNode != null) myMenuNode.Click();
        }

        public TreeNodeCollection Nodes
        {
            get { return this.myTreeView1.Nodes; }
        }

    }
    public class MyMenuNode: TreeNode
    {
        public event EventHandler MouseClick;
        public event EventHandler MouseHover;
        public event EventHandler MouseDoubleClick;

        public void Click()
        {
            if (MouseClick != null) MouseClick(this, null);
        }
        public void Hover()
        {
            if (MouseHover != null) MouseHover(this, null);
        }
        public void DoubleClick()
        {
            if (MouseDoubleClick != null) MouseDoubleClick(this, null);
        }
    }
}
